/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.basics.manager;

import java.io.File;

import com.genia.toolbox.basics.exception.technical.TechnicalException;
import com.genia.toolbox.basics.exception.technical.TechnicalIOException;

/**
 * interface for cryptography operations.
 */
public interface CryptoManager
{

  /**
   * return the hash for a string with MD5 algorithm.
   * 
   * @param string
   *          is of type <code>String</code>.
   * @return the hash for a string with MD5 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] md5(String string)
      throws TechnicalException;



  /**
   * return the hash for an array of <code>byte</code> with MD5 algorithm.
   * 
   * @param bytes
   *          is an array of <code>byte</code>.
   * @return the hash for an array of <code>byte</code> with MD5 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] md5(byte[] bytes)
      throws TechnicalException;



  /**
   * return the hash for a file with MD5 algorithm.
   * 
   * @param file
   *          is of type <code>File</code>.
   * @return the hash for a file with MD5 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   * @throws TechnicalIOException
   *           if the file is not found.
   */
  public abstract byte[] md5(File file)
      throws TechnicalIOException, TechnicalException;



  /**
   * return the hash for a string with SHA-1 algorithm.
   * 
   * @param string
   *          is of type <code>String</code>.
   * @return the hash for a string with SHA-1 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] sha1(String string)
      throws TechnicalException;



  /**
   * return the hash for an array of <code>byte</code> with SHA-1 algorithm.
   * 
   * @param bytes
   *          is an array of <code>byte</code>.
   * @return the hash for an array of <code>byte</code> with SHA-1 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] sha1(byte[] bytes)
      throws TechnicalException;



  /**
   * return the hash for a file with SHA-1 algorithm.
   * 
   * @param file
   *          is of type <code>File</code>.
   * @return the hash for a file with SHA-1 algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   * @throws TechnicalIOException
   *           if the file is not found.
   */
  public abstract byte[] sha1(File file)
      throws TechnicalIOException, TechnicalException;



  /**
   * return the hash for a string with default algorithm.
   * 
   * @param string
   *          is of type <code>String</code>.
   * @return the hash for a string with default algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] hash(String string)
      throws TechnicalException;



  /**
   * return the hash for an array of <code>byte</code> with default algorithm.
   * 
   * @param bytes
   *          is an array of <code>byte</code>.
   * @return the hash for an array of <code>byte</code> with default
   *         algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   */
  public abstract byte[] hash(byte[] bytes)
      throws TechnicalException;



  /**
   * return the hash for a file with default algorithm.
   * 
   * @param file
   *          is of type <code>File</code>.
   * @return the hash for a file with default algorithm.
   * @throws TechnicalException
   *           if the algorithm is not found.
   * @throws TechnicalIOException
   *           if the file is not found.
   */
  public abstract byte[] hash(File file)
      throws TechnicalIOException, TechnicalException;

}
